//
//  CorgiNavigationController.swift
//  weibo
//
//  Created by Corgi on 17/3/19.
//  Copyright © 2017年 cocoaHangTou. All rights reserved.
//

import UIKit

class CorgiNavigationController: UINavigationController,UIGestureRecognizerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.interactivePopGestureRecognizer?.delegate = self
    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        let count = viewControllers.count
        
        if count > 0 {
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: self, action: #selector(backClick))
            
            viewController.view.backgroundColor = UIColor.white
            
            viewController.hidesBottomBarWhenPushed = true
        }
        
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc private func backClick() {
        
        self.popViewController(animated: true)
        
    }
    
    func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        
        let count = viewControllers.count
        
        return count > 1
    }

}




